<include file="/public/header" />
<style>
    .layui-row {
        overflow: hidden;
        margin-bottom: 10px;
    }

    .echartsOrder {
        margin-right: 10px;
    }

    .echartsOrder:hover,
    .echartsOrder.active {
        color: #1890ff;
    }

    .products {
        width: 100%;
    }

    .layui-table th,
    .layui-table td {
        padding: 12px 15px;
        box-sizing: border-box;
        border: 1px solid #ebeef5;
    }

    .products td,
    .products th {
        padding: 12px 15px;
        box-sizing: border-box;
        border: 1px solid #ebeef5;
    }

    .products .label {
        text-align: center;
        background-color: #f5f7fa;
        font-weight: bold;
    }

    .title {
        font-weight: bold;
        padding: 15px 0;
        text-align: center;
        font-size: 18px;
    }
</style>

<div class="layui-fluid ">

    <div class="layui-row layui-col-space10">

        <div class="layui-col-md12">
            <!-- 填充内容 -->
            <!-- <div class="layui-card">
                <div class="layui-card-body" style="padding: 20px;">
                    <div class="layui-row">
                        <div class="layui-col-md12">
                            <img src="{$AdminLogin.face}" class="layui-admin-avatar">
                            <div class="layui-admin-content">
                                <span class="h4">欢迎您，{$AdminLogin.nickname|default=$AdminLogin.name}</span>
                                <span>开始您一天的工作吧！</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div> -->
            <div class="layui-card layui-col-xs12">
                <div class="layui-col-xs12 layui-col-md2">
                    <table class="layui-table" lay-skin="nob">
                        <colgroup>
                            <col width="50">
                            <col>
                            <col width="96">
                        </colgroup>
                        <thead>
                            <tr style="background: none;color: #333;">
                                <th colspan="3">产品库存预警前5<span style="color:red">(更多数据请在产品栏目查看)</span></th>
                            </tr>
                        </thead>
                        <tbody>
                            <volist name="$data.productlist" id="vo" key="k">
                                <tr>
                                    <td>
                                        <if condition="$k elt 2 "><span class="layui-badge layui-bg-cyan">{$k}</span>
                                        </if>
                                        <if condition="$k gt 2 "><span class="layui-badge layui-bg-gray">{$k}</span>
                                        </if>
                                    </td>
                                    <td>{$vo.title}</td>
                                    <td style="color:red">{$vo.stock}</td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                </div>
                <div class="layui-col-xs12 layui-col-md2">
                    <table class="layui-table" lay-skin="nob">
                        <colgroup>
                            <col width="50">
                            <col>
                            <col width="96">
                        </colgroup>
                        <thead>
                            <tr style="background: none;color: #333;">
                                <th colspan="3">原材料库存预警前5<span style="color:red">(更多数据请在原材料栏目筛选)</span></th>
                            </tr>
                        </thead>
                        <tbody>
                            <volist name="$data.materiallist" id="vo" key="k">
                                <tr>
                                    <td>
                                        <if condition="$k elt 2 "><span class="layui-badge layui-bg-cyan">{$k}</span>
                                        </if>
                                        <if condition="$k gt 2 "><span class="layui-badge layui-bg-gray">{$k}</span>
                                        </if>
                                    </td>
                                    <td>{$vo.title}</td>
                                    <td style="color:red">{$vo.sku}KG</td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                </div>
                <div class="layui-col-xs12 layui-col-md2">
                    <table class="layui-table" lay-skin="nob">
                        <colgroup>
                            <col width="50">
                            <col>
                            <col width="96">
                        </colgroup>
                        <thead>
                            <tr style="background: none;color: #333;">
                                <th colspan="3">原材料总进货量前5</th>
                            </tr>
                        </thead>
                        <tbody>
                            <volist name="$data.stock_weight" id="vo" key="k">
                                <tr>
                                    <td>
                                        <if condition="$k elt 2 "><span class="layui-badge layui-bg-cyan">{$k}</span>
                                        </if>
                                        <if condition="$k gt 2 "><span class="layui-badge layui-bg-gray">{$k}</span>
                                        </if>
                                    </td>
                                    <td>{$vo.materialtitle}</td>
                                    <td>{:floor($vo.mweight*100)/100}kg</td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                </div>
                <div class="layui-col-xs12 layui-col-md2">
                    <table class="layui-table" lay-skin="nob">
                        <colgroup>
                            <col width="50">
                            <col>
                            <col width="96">
                        </colgroup>
                        <thead>
                            <tr style="background: none;color: #333;">
                                <th colspan="3">原材料总进货金额前5</th>
                            </tr>
                        </thead>
                        <tbody>
                            <volist name="$data.stock_totals" id="vo" key="k">
                                <tr>
                                    <td>
                                        <if condition="$k elt 2 "><span class="layui-badge layui-bg-cyan">{$k}</span>
                                        </if>
                                        <if condition="$k gt 2 "><span class="layui-badge layui-bg-gray">{$k}</span>
                                        </if>
                                    </td>
                                    <td>{$vo.materialtitle}</td>
                                    <td>{:floor($vo.mtotals*100)/100}元</td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                </div>
                <div class="layui-col-xs12 layui-col-md2">
                    <table class="layui-table" lay-skin="nob">
                        <colgroup>
                            <col width="50">
                            <col>
                            <col width="96">
                        </colgroup>
                        <thead>
                            <tr style="background: none;color: #333;">
                                <th colspan="3">原材料总出货量前5</th>
                            </tr>
                        </thead>
                        <tbody>
                            <volist name="$data.out_weight" id="vo" key="k">
                                <tr>
                                    <td>
                                        <if condition="$k elt 2 "><span class="layui-badge layui-bg-cyan">{$k}</span>
                                        </if>
                                        <if condition="$k gt 2 "><span class="layui-badge layui-bg-gray">{$k}</span>
                                        </if>
                                    </td>
                                    <td>{$vo.materialtitle}</td>
                                    <td>{:floor($vo.mweight*100)/100}kg</td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                </div>
            </div>
            <div></div>
            <div class="layui-card">
                <div class="layui-card-header layadmin-card-header-auto ">
                    <div class="title">原材料数据自定义查询(排序不分先后)
                    </div>
                    <div class="layui-form">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <select name="materialid" lay-search="">
                                    <option value="">{:__('原材料，可搜索查询')}</option>
                                    <foreach $material as $v>
                                        <option value="{$v.id}">{$v.title}
                                        </option>
                                    </foreach>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline " style="width: 250px;">
                                    <input type="text" name="title" class="layui-input" placeholder="开始日期 至 开始日期数据"
                                        lay-datetime="" data-range="~" data-datetype="date" data-dateformat="yyyyMMdd">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <!-- // 默认搜索 -->
                                <button class="layui-btn icon-btn" lay-filter="formSearch" lay-submit><i
                                        class="layui-icon layui-icon-search"></i>{:__('搜索')}</button>
                                <div class="layui-divider layui-divider-vertical"></div>
                            </div>
                        </div>
                    </div>
                </div>
                <table id="lay-tableList" lay-filter="lay-tableList"></table>
            </div>
            <div class="layui-card">
                <div class="layui-card-header layadmin-card-header-auto ">
                    <div class="title">产品销量查询(排序不分先后)
                    </div>
                    <div class="layui-form">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <select name="products" lay-search="">
                                    <option value="">{:__('产品名称，可搜索查询')}</option>
                                    <foreach $product as $v>
                                        <option value="{$v.id}">{$v.title}
                                        </option>
                                    </foreach>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline " style="width: 250px;">
                                    <input type="text" name="titles" class="layui-input" placeholder="开始日期 至 开始日期数据"
                                        lay-datetime="" data-range="~" data-datetype="date" data-dateformat="yyyyMMdd">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <!-- // 默认搜索 -->
                                <button class="layui-btn icon-btn" lay-filter="formSearch2" lay-submit><i
                                        class="layui-icon layui-icon-search"></i>{:__('搜索')}</button>
                                <div class="layui-divider layui-divider-vertical"></div>
                            </div>
                        </div>
                    </div>
                </div>
                <table id="lay-tableList2" lay-filter="lay-tableList2"></table>
            </div>
        </div>
    </div>
</div>
<script src="__STATICADMIN__module/echarts/echarts.js"></script>
<include file="/public/footer" />
<script>
    layui.use(['admin', 'layedit', 'table', 'form', 'content'], function () {
        var admin = layui.admin;
        var table = layui.table;
        var form = layui.form;
        /*
         * 初始化表格
        */
        var isTable = table.render({
            elem: "#lay-tableList"
            , url: "{:url('/index/console')}"
            , page: true
            , cols: [[
                { field: 'title', align: 'center', title: '{:__("材料名称")}' },
                { field: 'stock_weight', align: 'center', title: '{:__("进货量(KG)")}' },
                { field: 'out_weight', align: 'center', title: '{:__("出货量(KG)")}' },
                { field: 'stock_totals', align: 'center', title: '{:__("进货金额(元)")}' },
                { field: 'stock_price', align: 'center', title: '{:__("进货均价(元/KG)")}' }
            ]],
            done: function () {
                //当数据渲染完后，执行的回调
            }
        })
    })

    layui.use(['admin', 'layedit', 'table', 'form', 'content'], function () {
        var admin = layui.admin;
        var table = layui.table;
        var form = layui.form;
        // 监听搜索 serialize
        form.on('submit(formSearch2)', function (data) {
            data.field.type = 2;
            var where = data.field;
            isTable2(where);
        })
        /*
         * 初始化表格
        */
        var isTable2 = function (where = []) {
            console.log(where);
            table.render({
                elem: "#lay-tableList2"
                , url: "{:url('/index/console')}",
                where: where
                , page: true
                , cols: [[
                    { field: 'title', align: 'center', title: '{:__("产品名称")}' },
                    { field: 'weightall', align: 'center', title: '{:__("生产总重(KG)")}' },
                    { field: 'guos', align: 'center', title: '{:__("生产总锅(锅)")}' },
                    { field: 'spec', align: 'center', title: '{:__("产品规格")}' },
                    { field: 'yuji', align: 'center', title: '{:__("预计入库件【增加库存和退单】")}' },
                    { field: 'rk', align: 'center', title: '{:__("实际入库件【增加库存和退单】")}' },
                    { field: 'rk2', align: 'center', title: '{:__("手动录入入库")}' },
                    { field: 'ck', align: 'center', title: '{:__("出库数量【减少库存和出单】")}' },
                    { field: 'price', align: 'center', title: '{:__("产品单价(元)")}' }
                ]],
                done: function () {
                    //当数据渲染完后，执行的回调
                }
            })
        }
        isTable2({'type':2});
    })
</script>
</body>

</html>